#------------------------------------------------------------------------------
# Figure 1. network size 
# see PI_models_trends_network_size.do
#==============================================================================

size <- as.data.frame(fread(here('results','tables','size_all_0708.csv')))

pdf(here('results','figures',"overall_0708.pdf"),paper="special",width=5,height=4)

size1 <- subset(size,outcome=="size3")

x <- size1$Year 
x[x==2016] <- c(2015.5,2016.5)
x[x==1987] <- c(1986.5,1987.5)
x[x==1992] <- c(1991.5,1992.5)
x[x==2006] <- c(2005.5,2006.5)

y <- size1$mean 
lci <- size1$"lower CI"
uci <- size1$"upper CI"

col <- ifelse(size1$name=="pol","red","blue")
pch <- ifelse(size1$name=="pol",1,19)

plot(x,y,ylim=c(1,2.5),xlim=c(1985,2017),col=col,pch=pch,xaxt="n",xlab="",
	ylab="Mean Network Size (cappted at 3)",main="Network Size")
axis(1,at=size1$Year[size1$Year!=2011],labels=as.character(size1$Year[size1$Year!=2011]),cex.axis=0.8,las=2)
for (i in 1:length(x)) lines(c(x[i],x[i]),c(lci[i],uci[i]),col=col[i])
legend("topright",c("important matters","political matters"),col=c("blue","red"),lty=1,bty="n",pch=c(19,1),cex=0.8)
dev.off()
